﻿using AutoMapper;
using Process.Api.DTO.InputDTO;
using Process.Domain.DTO.InputDTO;
using Process.Domain.DTO.InputDTO.Audit;
using Process.Domain.DTO.OutDTO;
using Process.Domain.Entities;

namespace Process.Api
{
    public class SqlsugarMapper : Profile
    {
        public SqlsugarMapper()
        {
            CreateMap<AddProcessDTO, ProcessModel>();
            CreateMap<ProcessModel, PagingProcessDTO>();
            CreateMap<UpdateProcessInput, ProcessModel>();
            CreateMap<ProcessModel, ShowprocessDTO>().ForMember(x => x.id, y => y.MapFrom(s => s.ProcessCode)).ForMember(x => x.name, y => y.MapFrom(s => s.ProcessName)).ForMember(x => x.description, y => y.MapFrom(s => s.ProcessDesc)).ForMember(x => x.ReadId, y => y.MapFrom(s => s.Id));


            CreateMap<AddOperationDTO, OperationModel>();
            CreateMap<OperationModel, PagingOperationDTO>();
            CreateMap<UpdateOperationInput, OperationModel>();

            // TimeReportingModel映射
            CreateMap<AddTimeReportingDTO, TimeReportingModel>();
            CreateMap<TimeReportingModel, PagingTimeReportingDTO>();
            CreateMap<UpdateTimeReportingInput, TimeReportingModel>();

            // TicketModel映射
            CreateMap<AddTicketDTO, TicketModel>();
            CreateMap<TicketModel, PagingTicketDTO>();
            CreateMap<UpdateTicketInput, TicketModel>();

            // DepartmentModel映射
            CreateMap<DepartmentModel, PagingDepartmentDTO>().ForMember(x => x.id, y => y.MapFrom(s => s.DepartmentCode)).ForMember(x => x.name, y => y.MapFrom(s => s.DepartmentName));
            CreateMap<DepartmentModel, ShowDepartmnetDTO>();

            CreateMap<OperationModel, ShowOperationDTO>().ForMember(x => x.id, y => y.MapFrom(s => s.OperationCode)).ForMember(x => x.name, y => y.MapFrom(s => s.OperationName)).ForMember(x=>x.description,y=>y.MapFrom(s=>s.OperationDesc));

            CreateMap<AddWorkflowDefinitionDTO, WorkflowDefinitionModel>();

            CreateMap<ProcessAuditModel, ShowAuditProcessDTO>();

            CreateMap<ProcessAuditModel, ShowAuditDataOut>();
        }
    }
}
